package com.ncst.backend.service.impl;

import com.ncst.backend.domain.Employee;
import com.ncst.backend.mapper.EmployeeMapper;
import com.ncst.backend.service.EmployeeService;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * 员工服务实现类
 */
@Slf4j
@Service
public class EmployeeServiceImpl implements EmployeeService {
    
    @Autowired
    private EmployeeMapper employeeMapper;
    
    @Override
    public Employee getById(Integer id) {
        return employeeMapper.selectById(id);
    }
    
    @Override
    public List<Employee> getAll() {
        return employeeMapper.selectAll();
    }
    
    @Override
    public List<Employee> getByCondition(Employee employee) {
        return employeeMapper.selectByCondition(employee);
    }
    
    @Override
    public List<Employee> getByPage(Integer pageNum, Integer pageSize) {
        Integer offset = (pageNum - 1) * pageSize;
        return employeeMapper.selectByPage(offset, pageSize);
    }
    
    @Override
    public Long countAll() {
        return employeeMapper.countAll();
    }
    
    @Override
    public Long countByCondition(Employee employee) {
        return employeeMapper.countByCondition(employee);
    }
    
    @Override
    public boolean save(Employee employee) {
        return employeeMapper.insert(employee) > 0;
    }
    
    @Override
    public boolean saveBatch(List<Employee> list) {
        return employeeMapper.insertBatch(list) > 0;
    }
    
    @Override
    public boolean updateById(Employee employee) {
        return employeeMapper.updateById(employee) > 0;
    }
    
    @Override
    public boolean removeById(Integer id) {
        return employeeMapper.deleteById(id) > 0;
    }
    
    @Override
    public boolean removeByIds(List<Integer> ids) {
        return employeeMapper.deleteByIds(ids) > 0;
    }
}
